﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace analysisText
{
    class readWordFile
    {
        String rutaArchivo;
        String textWord;
        public readWordFile(String pathFile)
        {
            rutaArchivo = pathFile;
            textWord = String.Empty;
        }

        public void readTextWord(){
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
            object miss = System.Reflection.Missing.Value;
            object path = @rutaArchivo;
            object readOnly = true;
            Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
            for (int i = 0; i < docs.Paragraphs.Count; i++)
            {
                textWord += " \r\n " + docs.Paragraphs[i + 1].Range.Text.ToString();
            }
            MessageBox.Show("Archivo Leido con exito");
        }

        public String getTextWord(){
            return textWord;
        }

    }
}
